package com.leyou.item.mapper;

import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.additional.idlist.SelectByIdListMapper;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface BrandMapper extends Mapper<Brand>, SelectByIdListMapper<Brand, Long> {

    @Insert("insert into tb_category_brand values (#{cid},#{bid})")
    void insertCategoryBrand(@Param("cid") Long cid, @Param("bid") Long bid);

    @Delete("delete from tb_category_brand where brand_id = #{bid}")
    void deleteCategory(@Param("bid") Long bid);

    @Select("SELECT tb.name,tb.id,tb.image,tb.letter FROM tb_brand tb inner JOIN tb_category_brand cb ON cb.brand_id = tb.id WHERE cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(Long cid);
}
